package com.empresa.androidchkapp.helpers;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateHelper {

	public static Date ValidaData(String date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd'T'HH:mm:ss.SSS");
		Date retorno = null;

		try {
			retorno = dateFormat.parse(date);
		} catch (ParseException e) {
			retorno = null;
		}

		return retorno;
	}
	
	public static String persistDate(Date date) {
	    if (date != null) {
	    	final SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");	    	
	        return parser.format(date);
	    }
	    return null;
	}

}
